/**
 * Home class
 *
 * @author Jose Luis Quintana <joseluis@lbn.pe>
 **/

var Co_Detail = new Class({
    name: 'Co_Detail',
    Extends: Main,
    Implements: [Events, Options],
    options: {
    
    },
//    detail: $('detail'),
//    path: $('path'),
    gallery: $('gallery'),
//    landscape: $('landscape'),
//    zoomerwrapper: $$('zoomer-wrapper'),
    
    initialize: function(options){
        this.parent();
        this.setOptions(options);
//        this.setZoom();
//        this.panelLeft();
//        this.setEvents();
//        this.setTooltips();
//        this.setScrollers();
    },
    setEvents: function(){
//        var container, panel_left = this.panel_left;
        
        window.addEvent('resize', function(){
//            container = this.getSizeContainer();
//            this.landscape.setStyle('width', 400);
//            this.landscape.setStyle('height', 400);
//            this.zoomerwrapper.setStyle('width', 400);
//            this.zoomerwrapper.setStyle('height', 400);
//            this.container.setStyle('height', this.getSizeContainer().y);
        }.bind(this));
    },
    setTooltips: function(){
        $$('li.tipz').each(function(element,index) {
            var content = element.get('title').split('::');
            element.store('tip:title', content[0]);
            element.store('tip:text', content[1]);
        });

        new Tips('.tipz', {
            showDelay: 0,
            hideDelay: 0,
            offset: {
                x: -100, 
                y: -80
            },
            className: 'tipz',
            fixed: true
        });
        
        /* Gallery */
        var preview = $('preview'), close = $('preview-close');
        close.addEvent('click', function(){
            this.gallery.setStyle('height', 'auto');
            preview.setStyle('display', 'none');
            close.setStyle('display', 'none');
        }.bind(this));
        
        $('gallery').getElements('img').each(function(e){
            e.addEvent('click', function(){
                $('gallery').getElements('img.selected').removeClass('selected');
                e.addClass('selected');
                this.gallery.setStyle('height', 1300);
                preview.set('src', e.get('src')).setStyle('display', 'block');
                close.setStyle('display', 'block');
                window.fireEvent('resize');
            }.bind(this));
        }.bind(this));
    },
    setScrollers: function(){
        new Scrollable($('detail'));
    }
});